#pragma once

#ifndef __CANVAS_REGEX_REGEXPURE_H
#define __CANVAS_REGEX_REGEXPURE_H

#include "..\Objects.h"
#include "RegExAutomation.h"

namespace Canvas
{
	namespace RegExInternal
	{
		class PureResult
		{
		public:
			int start;
			int length;
			int finalState;
			int terminateState;
		};

		class PureInterpreter : public Object
		{
		protected:
			static const int SupportedCharCount = 0x10000;
			int charMap[SupportedCharCount];
			int** transition;
			bool* finalState;
			int* relatedFinalState;
			int stateCount;
			int charSetCount;
			int startState;

		public:
			PureInterpreter(Automation::Ref dfa, CharRange::List& subsets);
			~PureInterpreter();

			bool MatchHead(const wchar_t* input, const wchar_t* start, PureResult& result);
			bool Match(const wchar_t* input, const wchar_t* start, PureResult& result);
			
			int GetStartState();
			int Transit(wchar_t input, int state);
			bool IsFinalState(int state);
			bool IsDeadState(int state);

			void PrepareForRelateFinalStateTable();
			int GetRelatedFinalState();
		};
	}
}


#endif // __CANVAS_REGEX_REGEXPURE_H